package com.luo.chengrui.module.sa.dal.mysql.auth;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.auth.AuthorizeDO;
import com.luo.chengrui.module.sa.dal.dataobject.auth.AuthorizeViewDO;
import com.luo.chengrui.module.sa.dal.dataobject.role.PermissionDO;
import com.luo.chengrui.module.sa.dal.dataobject.role.RoleFolderUserViewDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.auth.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;

/**
 * 角色授权  Mapper
 *
 * @author 诚睿
 */
@Mapper
public interface AuthorizeMapper extends BaseMapperX<AuthorizeDO> {

    default PageResult<AuthorizeDO> selectPage(AuthorizePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AuthorizeDO>()
                .eqIfPresent(AuthorizeDO::getOrgId, reqVO.getOrgId())
                .likeIfPresent(AuthorizeDO::getOrgName, reqVO.getOrgName())
                .likeIfPresent(AuthorizeDO::getOrgFullId, reqVO.getOrgFullId())
                .likeIfPresent(AuthorizeDO::getOrgFullName, reqVO.getOrgFullName())
                .eqIfPresent(AuthorizeDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(AuthorizeDO::getVersion, reqVO.getVersion())
                .orderByDesc(AuthorizeDO::getId));
    }

    default List<AuthorizeDO> selectList(AuthorizeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AuthorizeDO>()
                .eqIfPresent(AuthorizeDO::getOrgId, reqVO.getOrgId())
                .likeIfPresent(AuthorizeDO::getOrgName, reqVO.getOrgName())
                .likeIfPresent(AuthorizeDO::getOrgFullId, reqVO.getOrgFullId())
                .likeIfPresent(AuthorizeDO::getOrgFullName, reqVO.getOrgFullName())
                .eqIfPresent(AuthorizeDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(AuthorizeDO::getVersion, reqVO.getVersion())
                .orderByDesc(AuthorizeDO::getId));
    }

    IPage<AuthorizeDO> selectPageCustomize(IPage<T> mpPage, @Param("params") AuthorizePageReqVO pageVO);

    List<AuthorizeViewDO> selectListCustomize(@Param("fullId") String fullId);

    default List<AuthorizeDO> selectListByFullId(String orgFullId) {
        return selectList(AuthorizeDO::getOrgFullId, orgFullId);
    }
}
